home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / client / trans / 2PC.c next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.6 KB  |  154 lines

  1. /*
  2.  *   $RCSfile: 2PC.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:30 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "trans.h"
  51. #include "bf.h"
  52. #include "chunk.h"
  53. #include "serverinfo.h"
  54. #include "bf_extfuncs.h"
  55. #include "trans_funcs.h"
  56. #include "msg_funcs.h"
  57. #include "trans_globals.h"
  58. #include "msg_globals.h"
  59.  
  60.  
  61.  int
  62. continue2PC (
  63.  
  64.     TRANSREC    *transRec
  65. )
  66. {
  67.     MESSAGE        message;
  68.  
  69.     TRACE(TR_TRANS, TR_LEVEL_1);
  70.  
  71.     message.header.params.in.tid = transRec->coordTid;
  72.     message.header.type = CONTINUE_2PC;
  73.     message.header.replyRequested = TRUE;
  74.  
  75.     /*
  76.      *    request a transaction id from the server    
  77.      */
  78.     if (callServer(transRec->coordInfo, &message, NULL, 0 ) != esmNOERROR)    {
  79.  
  80.         if (message.header.params.out.errno == esmBADTRANSID) 
  81.             endTransForAllServers(transRec, ABORT_TRANS);
  82.  
  83.         return(esmFAILURE);
  84.     }
  85.  
  86.     return(esmNOERROR);
  87. }
  88.  
  89.  int
  90. enter2PC (
  91.  
  92.     SERVERINFO    *serverInfo,
  93.     TID            *coordTid,
  94.     GTID        *gtid
  95. )
  96. {
  97.     MESSAGE        message;
  98.  
  99.     /*
  100.      * have to go to the coord to get a coord-tid, which
  101.      * serves as the GLOBAL-TID-THREAD-ID
  102.      * so that we can distinguish this thread of a GTX from
  103.      * another exodus thread of the same GTX
  104.      */
  105.  
  106.     TRACE(TR_TRANS, TR_LEVEL_1);
  107.  
  108.     message.header.type = ENTER2PC;
  109.     message.header.replyRequested = TRUE;
  110.  
  111.  
  112.     /*
  113.      *    request a transaction id from the server    
  114.      */
  115.     if (callServer(serverInfo, &message, (char *)gtid, sizeof(GTID) ) != esmNOERROR)    {
  116.  
  117.         return(esmFAILURE);
  118.     }
  119.  
  120.     if(coordTid != NULL)
  121.         *coordTid = message.body.trans.tid;    
  122.     TRPRINT(TR_TRANS, TR_LEVEL_2, ("coordTid:%d", coordTid?*coordTid:0));
  123.  
  124.     return(esmNOERROR);
  125. }
  126.  
  127.  int
  128. recover2PC (
  129.  
  130.     COORD_HANDLE    *handle,
  131.     SERVERINFO        *coordInfo
  132. )
  133. {
  134.     MESSAGE        message;
  135.  
  136.     TRACE(TR_TRANS, TR_LEVEL_1);
  137.  
  138.     message.header.params.in.tid = handle->coordTid;
  139.     message.header.type = RECOVER_2PC;
  140.     message.header.replyRequested = TRUE;
  141.  
  142.     /*
  143.      *    request a transaction id from the server    
  144.      */
  145.     if (callServer(coordInfo, &message, NULL, 0 ) != esmNOERROR)    {
  146.  
  147.         return(esmFAILURE);
  148.     }
  149.  
  150.     TRPRINT(TR_DISTR|TR_TRANS, TR_LEVEL_2, ("recovered coordTid:%d", handle->coordTid));
  151.  
  152.     return(esmNOERROR);
  153. }
  154.